package com.suneee.base.sendmsg.sms;

import java.util.Arrays;
import java.util.List;

import com.suneee.base.sendmsg.ISendMsgService;
import com.suneee.base.sendmsg.bean.SendMsgBean;
import com.suneee.base.sendmsg.wsclient.SmsResultOut;
import com.suneee.base.sendmsg.wsclient.SmsSenderV2Service;

public class SendSmsMsgServiceImpl implements ISendMsgService{

	private String	smsSignature	= null;

	public void setSmsSignature(String smsSignature){
		this.smsSignature = smsSignature;
	}
	
	@Override
	public boolean sendMsg(SendMsgBean sendBean) {
		SmsSenderV2Service service = new SmsSenderV2Service();
		String split = ",";

		List<String> receiveList = SendSmsMsgServiceImpl.stringToList(sendBean.getRecievePerson(), split);

		SmsResultOut result = service.getSmsSenderV2Port().sendSms(receiveList, sendBean.getContent(), smsSignature, null);
		return "success".equalsIgnoreCase(result.getResultCode());
		
	}

	public static List<String> stringToList(String str, String split){
		String[] arr = str.split(split);
		return Arrays.asList(arr);
	}
}
